<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>豆包</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            font-family: Arial, sans-serif;
            background-color: #f8f8f8;
            display: flex;
            height: 100vh;
        }
        .container {
            display: flex;
            width: 90%;
            max-width: 1200px;
        }
        .sidebar {
            width: 25%;
            padding: 20px;
            background-color: #f0f2f5;
            border-right: 1px solid #e0e0e0;
        }
        .content {
            width: 75%;
            padding: 40px;
            position: relative;
        }
        .sidebar h2 {
            font-size: 1.5em;
            margin-bottom: 20px;
        }
        .sidebar ul {
            list-style: none;
        }
        .sidebar ul li {
            padding: 10px 0;
            font-size: 1em;
            color: #333;
            cursor: pointer;
        }
        .sidebar ul li:hover {
            color: #0078ff;
        }
        .content h1 {
            font-size: 2em;
            margin-bottom: 10px;
        }
        .content p {
            font-size: 1.2em;
            color: #666;
        }
        .card-container {
            display: flex;
            flex-wrap: wrap;
            margin-top: 20px;
            gap: 10px;
        }
        .card {
            width: calc(50% - 10px);
            padding: 20px;
            background-color: #fff;
            border-radius: 10px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            text-align: center;
            cursor: pointer;
            transition: transform 0.3s;
        }
        .card:hover {
            transform: scale(1.05);
        }
        .card h3 {
            font-size: 1.2em;
            color: #333;
            margin-bottom: 10px;
        }
        .footer {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-top: 20px;
            color: #999;
        }
        .footer div {
            cursor: pointer;
        }
        .footer div:hover {
            color: #0078ff;
        }
        .chat-container {
            width: 100%;
            max-width: 1000px;
            height: 600px;
            overflow-y: auto;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 10px;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            margin-top: 20px;
        }
        .message-container {
            display: flex;
            flex-direction: row;
            margin-bottom: 10px;
        }
        .user-message {
            margin-left: auto;
            background-color: #4CAF50;
            color: white;
            padding: 10px;
            border-radius: 5px;
        }
        .bot-message {
            margin-right: auto;
            background-color: #ccc;
            color: black;
            padding: 10px;
            border-radius: 5px;
        }
        .input-container {
            margin-top: 10px;
            display: flex;
            align-items: center;
        }
        .input-container input[type="text"] {
            flex: 1;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        .input-container button {
            margin-left: 10px;
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="sidebar">
            <h2><img src = doubao.jpg width = 45px height = 45px>豆包</h2>
            <button style="margin-bottom: 20px;">新对话</button>
            <ul>
                <li>AI 搜索</li>
                <li>帮助写作</li>
                <li>图像生成
                 <button class="imageGenButton">图像生成</button>
                </li>
                <li>AI 阅读</li>
            </ul>
            <ul style="margin-top: 20px;">
                <li>最近对话</li>
                <li>我的智能体</li>
                <li>收藏夹</li>
            </ul>
        </div>
        <div class="content">
            <p>我可以如何帮助到你？</p>
            <div class="card-container">
                <div class="card">
                    <h3>AI 搜索</h3>
                    <p>实时资讯，丰富信息，整合搜索</p>
                </div>
                <div class="card">
                    <h3>帮助写作</h3>
                    <p>多种代写，润色校对，一键成文</p>
                </div>
                <div class="card">
                    <button class="imageGenButton">
                    <h3>图像生成</h3>
                    <p>自定义风格，搜集灵感，复制同款</p>
                     </button>
                </div>
                <div class="card">
                    <h3>AI 阅读</h3>
                    <p>论文讲解，财报合同，翻译总结</p>
                </div>
            </div>
            <div class="chat-container" id="chat-window"></div>
            <!-- 输入框和发送按钮 -->
            <form id="myForm" class="input-container">
                <input type="text" id="input" name="input" placeholder="输入你的问题..." required>
                <button type="submit">发送</button>
            </form>

            <div class="footer">
                <div>AI 搜索</div>
                <div>帮助写作</div>
                 <button class="imageGenButton">
                     <div>图像生成 </div>
                 </button>
                <div>更多</div>
            </div>
        </div>
    </div>
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script>
        $(document).ready(function() {
            $('#myForm').submit(function(event) {
                event.preventDefault();
                var input = $('#input').val();  // 获取输入框的内容
                // 创建新的用户消息
                var message = $('<div class="message-container"></div>');
                var userMessage = $('<div class="user-message"></div>').text(input);
                // 将用户消息添加到聊天窗口
                message.append(userMessage);
                $('#chat-window').append(message);
                // AJAX POST请求到后端接口
                $.ajax({
                    url: '/',  // 假设后端接口位于 '/'
                    type: 'post',
                    contentType: 'application/json',
                    data: JSON.stringify({ "input": input }),  // 将输入数据转为JSON格式
                    success: function(response) {
                        // 创建新的机器人消息
                        var message = $('<div class="message-container"></div>');
                        var botMessage = $('<div class="bot-message"></div>').text(response.msg);
                        // 将机器人消息添加到聊天窗口
                        message.append(botMessage);
                        $('#chat-window').append(message);
                        // 滚动到最底部以显示最新消息
                        $('#chat-window').scrollTop($('#chat-window')[0].scrollHeight);
                    },
                    error: function(xhr, status, error) {
                        console.log(error);
                    }
                });
                // 清空输入框
                $('#input').val('');
            });

        });
    </script>
   <script>
    $(document).ready(function() {
        $('.imageGenButton').click(function() {
            location.assign('zuotu.html');
        });
    });
</script>
</body>
</html>